package com.example.a2032.activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.a2032.R;
import com.example.a2032.Utils.Utils;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class GoalTipsActivity extends BaseActivity {

    @BindView(R.id.textView_goalPercent)
    TextView textViewGoalPercent;
    public static final String Goal_Percent = "Goal_Percent";
    @BindView(R.id.imageView)
    ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goal_tips);
        ButterKnife.bind(this);
        init();
    }

    Disposable disposable;

    private void init() {
        int percent = getIntent().getIntExtra(Goal_Percent, 0);
        textViewGoalPercent.setText(percent==0?"50%":"100%");
        imageView.setImageResource(percent==0?R.drawable.goal_50:R.drawable.goal_100);
        Utils.startMeasureTimer(5, TimeUnit.SECONDS, new Observer() {
            @Override
            public void onSubscribe(Disposable d) {
                disposable = d;
            }

            @Override
            public void onNext(Object o) {
                finish();
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unSubscribe(disposable);
    }
}